<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function delay(s) {
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve(`延迟了${s}秒`)
        })
      })
    }
    async function fun1() {
      const res1 = await delay(1)
      console.log('res1', res1)
      const res2 = await delay(3)
      console.log('res2', res2)
    }
    async function fun2() {
      const res3 = await delay(2)
      console.log('res3', res3)
      const res4 = await delay(4)
      console.log('res4', res4)
    }
    fun1()
    fun2()
    // res1 res3 res2 res4
    // await函数只能影响async函数内部的执行顺序，并不能影响外部函数的执行顺序
  </script>
</body>

</html>